﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ZLCMS.Web.SystemManage.Control.ddt
{
    public partial class DropDownTreeControl : System.Web.UI.UserControl
    {
        public int SelectedNodeId 
        {
            get
            {
                if (String.IsNullOrEmpty(inpNodeValue.Value))
                {
                    return -1;
                }
                try
                {
                    return Int32.Parse(inpNodeValue.Value);
                }
                catch (System.Exception)
                {
                    return -1;
                }
            }
            set
            {
                inpNodeValue.Value = value.ToString();
            }
        }

        public string SelectedNodeText 
        { 
            get 
            { 
                return txtNodeText.Text; 
            } 
            set
            {
                txtNodeText.Text = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        /// <summary>
        /// 数据来源的URL
        /// </summary>
        public string DataFromUrl { get; set; }

        /// <summary>
        /// 传入URL的类型参数，根据具体实现的类来确定，如果没有则填空
        /// </summary>
        public string Kind { get; set; }

        /// <summary>
        /// 传入URL的树结构的根ID，根据具体实现的类来确定，如果没有则填空
        /// </summary>
        public string RootNode { get; set; }
       
        protected string AsyncUrl
        {
            get
            {
                if (DataFromUrl.Contains('?'))
                {
                    return DataFromUrl + "&Kind=" + Kind + "&RootNode=" + RootNode;
                } 
                else
                {
                    return DataFromUrl + "?Kind=" + Kind + "&RootNode=" + RootNode;
                }
            }
          
        }
    }
}